; RUN: clspv-opt %s -o %t.ll --passes=allocate-descriptors
; RUN: FileCheck %s < %t.ll

; CHECK: call ptr addrspace(1) @_Z14clspv.resource.0(i32 0, i32 0, i32 0, i32 0, i32 0, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.1(i32 0, i32 1, i32 0, i32 1, i32 1, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.2(i32 0, i32 2, i32 0, i32 2, i32 2, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.3(i32 0, i32 3, i32 0, i32 3, i32 3, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.4(i32 0, i32 4, i32 0, i32 4, i32 4, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.5(i32 0, i32 5, i32 0, i32 5, i32 5, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.6(i32 0, i32 6, i32 0, i32 6, i32 6, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.7(i32 0, i32 7, i32 0, i32 7, i32 7, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.8(i32 0, i32 8, i32 0, i32 8, i32 8, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.9(i32 0, i32 9, i32 0, i32 9, i32 9, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.10(i32 0, i32 10, i32 0, i32 10, i32 10, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.11(i32 0, i32 11, i32 0, i32 11, i32 11, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.12(i32 0, i32 12, i32 0, i32 12, i32 12, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.13(i32 0, i32 13, i32 0, i32 13, i32 13, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.14(i32 0, i32 14, i32 0, i32 14, i32 14, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.15(i32 0, i32 15, i32 0, i32 15, i32 15, i32 0, { [0 x i64] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.16(i32 0, i32 16, i32 0, i32 16, i32 16, i32 0, { [0 x i32] } zeroinitializer)
; CHECK: call ptr addrspace(1) @_Z14clspv.resource.17(i32 0, i32 17, i32 0, i32 17, i32 17, i32 0, { [0 x i32] } zeroinitializer)

target datalayout = "e-p:32:32-i64:64-v16:16-v24:32-v32:32-v48:64-v96:128-v192:256-v256:256-v512:512-v1024:1024"
target triple = "spir-unknown-unknown"

define dso_local spir_kernel void @test(ptr addrspace(1) align 4 %in1, ptr addrspace(1) align 4 %in2, ptr addrspace(1) align 8 %in3, ptr addrspace(1) align 8 %in4, ptr addrspace(1) align 4 %in5, ptr addrspace(1) align 4 %in6, ptr addrspace(1) align 8 %in7, ptr addrspace(1) align 8 %in8, ptr addrspace(1) align 4 %in9, ptr addrspace(1) align 4 %in10, ptr addrspace(1) align 8 %in11, ptr addrspace(1) align 8 %in12, ptr addrspace(1) align 4 %in13, ptr addrspace(1) align 4 %in14, ptr addrspace(1) align 8 %in15, ptr addrspace(1) align 8 %in16, ptr addrspace(1) align 4 %in17, ptr addrspace(1) align 4 %in18) !clspv.pod_args_impl !8 {
entry:
  %0 = addrspacecast ptr addrspace(1) %in1 to ptr addrspace(4)
  %call = call spir_func i32 @_Z11atomic_loadPU3AS4VU7_Atomici(ptr addrspace(4) %0)
  %1 = addrspacecast ptr addrspace(1) %in2 to ptr addrspace(4)
  %call1 = call spir_func i32 @_Z20atomic_load_explicitPU3AS4VU7_Atomicj12memory_order(ptr addrspace(4) %1, i32 0)
  %2 = addrspacecast ptr addrspace(1) %in3 to ptr addrspace(4)
  %call2 = call spir_func i64 @_Z15atomic_exchangePU3AS4VU7_Atomicll(ptr addrspace(4) %2, i64 0)
  %3 = addrspacecast ptr addrspace(1) %in4 to ptr addrspace(4)
  %call3 = call spir_func i64 @_Z24atomic_exchange_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4) %3, i64 0, i32 0)
  %4 = addrspacecast ptr addrspace(1) %in5 to ptr addrspace(4)
  %call4 = call spir_func i32 @_Z16atomic_fetch_addPU3AS4VU7_Atomicii(ptr addrspace(4) %4, i32 0)
  %5 = addrspacecast ptr addrspace(1) %in6 to ptr addrspace(4)
  %call5 = call spir_func i32 @_Z25atomic_fetch_add_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4) %5, i32 0, i32 0)
  %6 = addrspacecast ptr addrspace(1) %in7 to ptr addrspace(4)
  %call6 = call spir_func i64 @_Z16atomic_fetch_subPU3AS4VU7_Atomicll(ptr addrspace(4) %6, i64 0)
  %7 = addrspacecast ptr addrspace(1) %in8 to ptr addrspace(4)
  %call7 = call spir_func i64 @_Z25atomic_fetch_sub_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4) %7, i64 0, i32 0)
  %8 = addrspacecast ptr addrspace(1) %in9 to ptr addrspace(4)
  %call8 = call spir_func i32 @_Z15atomic_fetch_orPU3AS4VU7_Atomicii(ptr addrspace(4) %8, i32 0)
  %9 = addrspacecast ptr addrspace(1) %in10 to ptr addrspace(4)
  %call9 = call spir_func i32 @_Z24atomic_fetch_or_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4) %9, i32 0, i32 0)
  %10 = addrspacecast ptr addrspace(1) %in11 to ptr addrspace(4)
  %call10 = call spir_func i64 @_Z16atomic_fetch_xorPU3AS4VU7_Atomicll(ptr addrspace(4) %10, i64 0)
  %11 = addrspacecast ptr addrspace(1) %in12 to ptr addrspace(4)
  %call11 = call spir_func i64 @_Z25atomic_fetch_xor_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4) %11, i64 0, i32 0)
  %12 = addrspacecast ptr addrspace(1) %in13 to ptr addrspace(4)
  %call12 = call spir_func i32 @_Z16atomic_fetch_andPU3AS4VU7_Atomicii(ptr addrspace(4) %12, i32 0)
  %13 = addrspacecast ptr addrspace(1) %in14 to ptr addrspace(4)
  %call13 = call spir_func i32 @_Z25atomic_fetch_and_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4) %13, i32 0, i32 0)
  %14 = addrspacecast ptr addrspace(1) %in15 to ptr addrspace(4)
  %call14 = call spir_func i64 @_Z16atomic_fetch_minPU3AS4VU7_Atomicll(ptr addrspace(4) %14, i64 0)
  %15 = addrspacecast ptr addrspace(1) %in16 to ptr addrspace(4)
  %call15 = call spir_func i64 @_Z25atomic_fetch_min_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4) %15, i64 0, i32 0)
  %16 = addrspacecast ptr addrspace(1) %in17 to ptr addrspace(4)
  %call16 = call spir_func i32 @_Z16atomic_fetch_maxPU3AS4VU7_Atomicii(ptr addrspace(4) %16, i32 0)
  %17 = addrspacecast ptr addrspace(1) %in18 to ptr addrspace(4)
  %call17 = call spir_func i32 @_Z25atomic_fetch_max_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4) %17, i32 0, i32 0)
  ret void
}

declare spir_func i32 @_Z11atomic_loadPU3AS4VU7_Atomici(ptr addrspace(4))
declare spir_func i32 @_Z20atomic_load_explicitPU3AS4VU7_Atomicj12memory_order(ptr addrspace(4), i32)
declare spir_func i64 @_Z15atomic_exchangePU3AS4VU7_Atomicll(ptr addrspace(4), i64)
declare spir_func i64 @_Z24atomic_exchange_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4), i64, i32)
declare spir_func i32 @_Z16atomic_fetch_addPU3AS4VU7_Atomicii(ptr addrspace(4), i32)
declare spir_func i32 @_Z25atomic_fetch_add_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4), i32, i32)
declare spir_func i64 @_Z16atomic_fetch_subPU3AS4VU7_Atomicll(ptr addrspace(4), i64)
declare spir_func i64 @_Z25atomic_fetch_sub_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4), i64, i32)
declare spir_func i32 @_Z15atomic_fetch_orPU3AS4VU7_Atomicii(ptr addrspace(4), i32)
declare spir_func i32 @_Z24atomic_fetch_or_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4), i32, i32)
declare spir_func i64 @_Z16atomic_fetch_xorPU3AS4VU7_Atomicll(ptr addrspace(4), i64)
declare spir_func i64 @_Z25atomic_fetch_xor_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4), i64, i32)
declare spir_func i32 @_Z16atomic_fetch_andPU3AS4VU7_Atomicii(ptr addrspace(4), i32)
declare spir_func i32 @_Z25atomic_fetch_and_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4), i32, i32)
declare spir_func i64 @_Z16atomic_fetch_minPU3AS4VU7_Atomicll(ptr addrspace(4), i64)
declare spir_func i64 @_Z25atomic_fetch_min_explicitPU3AS4VU7_Atomicmm12memory_order(ptr addrspace(4), i64, i32)
declare spir_func i32 @_Z16atomic_fetch_maxPU3AS4VU7_Atomicii(ptr addrspace(4), i32)
declare spir_func i32 @_Z25atomic_fetch_max_explicitPU3AS4VU7_Atomicjj12memory_order(ptr addrspace(4), i32, i32)

!8 = !{i32 1}

